﻿using System;
using System.Collections.Generic;
using System.Data;
using DAL;
using Entities;

namespace BLL
{
    public class BLL_MailBox
    {
        private DAL_MailBox dal_MailBox = new DAL_MailBox();

        public DataTable Get_MailBox_All()
        {
            return dal_MailBox.Get_MailBox_All();
        }

        public DataTable Get_MailBox(Int64 pID)
        {
            return dal_MailBox.Get_MailBox(pID);
        }

        public DataTable Get_MailBox_Dynamic(string pCondition)
        {
            return dal_MailBox.Get_MailBox_Dynamic(pCondition);
        }

        public List<MailBox> Lst_MailBox(DataTable pdt)
        {
            List<MailBox> lstReturn = new List<MailBox>();
            if (pdt != null && pdt.Rows.Count > 0)
            {
                foreach (DataRow dr in pdt.Rows)
                {
                    MailBox mailBox = new MailBox();
                    mailBox.EMAIL = Convert.ToString(dr["EMAIL"]);
                    mailBox.ID = (dr["ID"] == DBNull.Value ? 0 : Convert.ToInt32(dr["ID"]));
                    mailBox.FULLNAME = Convert.ToString(dr["FULLNAME"]);
                    mailBox.INFORMATION = Convert.ToString(dr["INFORMATION"]);
                    mailBox.SEND_DATE = (dr["SEND_DATE"] == DBNull.Value ? DateTime.Now : Convert.ToDateTime(dr["SEND_DATE"]));

                    lstReturn.Add(mailBox);
                }
            }
            return lstReturn;
        }

        public bool InsertUpdate_MailBox(MailBox pMailBox)
        {
            return dal_MailBox.InsertUpdate_MailBox(pMailBox);
        }

        public bool DeleteMailBox(Int64 pID)
        {
            return dal_MailBox.DeleteMailBox(pID);
        }
    }
}
